import java.io.BufferedReader;
import java.io.InputStreamReader;

import es.deusto.ingenieria.is.csp.algorithm.BackTracking;

public class MainProgram {
	
	public static void main(String args[]) {
		try {
			System.out.print("* Name of the board file (.xml): ");
			
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); 
			String file = br.readLine().trim().toLowerCase();
			
			if (!file.endsWith(".xml")) {
				file += ".xml";
			}
						
			GemProblem problem = new GemProblem("data/" + file);			
			System.out.println("\n" + problem);
			
			if (new BackTracking<Gem>().solve(problem)) {
				System.out.println("\n* Gem problem solved :-)\n");
			} else {
				System.out.println("\n* Gem problem has no solution :-(\n");
			}
			
			System.out.println(problem);
		} catch (Exception ex) {
			ex.printStackTrace();
		}		
	}
}
